<?php
require_once dirname(__FILE__) . "/../../includes/config.php";
require_once PHP_ROOTPATH.'/classes/database.php';
 
 //récupération des unite_mesure en fonction de la description sélectionnée
header("Content-Type: text/xml; charset=utf-8");
echo "<?xml version=\"1.0\" encoding=\"utf-8\"?>";
echo "<list>";
 
$groupe = (isset($_POST["description"])) ? html_entity_decode($_POST["description"]) : NULL;

if ($groupe) {
    $id_connect=Database::getInstance();
    $query_temp = "SELECT DISTINCT(unite_mesure) FROM type_test WHERE description='".pg_escape_string($groupe) ."' ORDER BY unite_mesure";
    $res_query = pg_query($id_connect , $query_temp) or die(pg_last_error());
    while ($back = pg_fetch_assoc($res_query)) {
		echo $back["unite_mesure"];
        echo "<item class=\"box\" name=\"" . $back["unite_mesure"] . "\" />";
    }
}

echo "</list>";
?>